AbiPy v0.9.1 @IMEC

M. Giantomassi and the AbiPy group

10th international ABINIT developer workshop
May 31 - June 4, 2021 - Smart Working, Lockdown@BE


Use the Space key to navigate through all slides and SHIFT + Space key to go back one slide.

What is AbiPy?

Python package for:

  • Generating ABINIT input files automatically
  • Post-processing results extracted from netcdf or text files
  • Interfacing ABINIT with external tools such as vesta, wannier90, lobster, etc.
  • Running ABINIT-specific workflows on laptops as well as on HPC clusters

Dependencies:

NB: AbiPy can be interfaced with other packages (e.g ASE, phonopy) via converters.

How to install AbiPy

Using conda and the conda forge channel (recommended):

    conda install abipy --channel conda-forge

Since conda is not limited to python packages, one can install ABINIT in the same env with:

    conda install abinit -c conda-forge      


Using pip and python wheels:

    pip install abipy --user


For further info see this installation howto

Jupyter notebooks with examples and lessons inspired by the official tutorials

In [4]:
%embed https://nbviewer.jupyter.org/github/abinit/abitutorials/blob/master/abitutorials/index.ipynb
Out[4]:

  • Since AbiPy is not restricted to high-throughput, we'll show how to use the terminal to analyze calculations

  • Well, a python script would be much more flexible but the goal here is to show that one can replace grep, vim, gnuplot with AbiPy

  • Then we show how to use the python API for improved flexibility
No perl scripts were harmed in the making of this notebook

Command line interface

  • abiopen.py ➝ Open output files inside ipython or print/visualize file
  • abistruct.py ➝ Operate on crystalline structures read from file
  • abicomp.py ➝ Compare multiple files (i.e. convergence studies)
  • abiview.py ➝ Quick visualization of output files
  • abinp.py ➝ Generate input files for typical calculations
  • abigui.py ➝ Start GUI in web browser

Documentation

  • abistruct.py --help for manpage
  • abistruct.py COMMAND --help for help about COMMAND

HTML documentation available at http://abinit.github.io/abipy/scripts/index.html

Examples

abistruct.py spglib si_scf_GSR.nc
abistruct.py convert si_scf_GSR.nc -f cif
abiopen.py si_scf_GSR.nc --print

and many more...

abiopen.py

In [5]:
!abiopen.py si_scf_GSR.nc --print
================================= File Info =================================
Name: si_scf_GSR.nc
Directory: /Users/gmatteo/git_repos/abipy_imec_2022
Size: 14.83 kb
Access Time: Mon Jun  6 23:58:53 2022
Modification Time: Mon Jun  6 23:53:36 2022
Change Time: Mon Jun  6 23:53:36 2022

================================= Structure =================================
Full Formula (Si2)
Reduced Formula: Si
abc   :   3.866975   3.866975   3.866975
angles:  60.000000  60.000000  60.000000
Sites (2)
  #  SP       a     b     c  cartesian_forces
---  ----  ----  ----  ----  -----------------------------------------------------------
  0  Si    0     0     0     [-5.89948306e-27 -1.93366149e-27  2.91016904e-27] eV ang^-1
  1  Si    0.25  0.25  0.25  [ 5.89948306e-27  1.93366149e-27 -2.91016904e-27] eV ang^-1

Abinit Spacegroup: spgid: 227, num_spatial_symmetries: 48, has_timerev: True, symmorphic: True

Stress tensor (Cartesian coordinates in GPa):
[[5.21161758e+00 7.86452261e-11 0.00000000e+00]
 [7.86452261e-11 5.21161758e+00 0.00000000e+00]
 [0.00000000e+00 0.00000000e+00 5.21161758e+00]]

Pressure: -5.212 (GPa)
Energy: -241.23647031 (eV)

============================== Electronic Bands ==============================
Number of electrons: 8.0, Fermi level: 5.598 (eV)
nsppol: 1, nkpt: 29, mband: 8, nspinor: 1, nspden: 1
smearing scheme: none (occopt 1), tsmear_eV: 0.272, tsmear Kelvin: 3157.7
Direct gap:
    Energy: 2.532 (eV)
    Initial state: spin: 0, kpt: [+0.000, +0.000, +0.000], weight: 0.002, band: 3, eig: 5.598, occ: 2.000
    Final state:   spin: 0, kpt: [+0.000, +0.000, +0.000], weight: 0.002, band: 4, eig: 8.130, occ: 0.000
Fundamental gap:
    Energy: 0.562 (eV)
    Initial state: spin: 0, kpt: [+0.000, +0.000, +0.000], weight: 0.002, band: 3, eig: 5.598, occ: 2.000
    Final state:   spin: 0, kpt: [+0.375, +0.375, +0.000], weight: 0.012, band: 4, eig: 6.161, occ: 0.000
Bandwidth: 11.856 (eV)
Valence maximum located at kpt index 0:
    spin: 0, kpt: [+0.000, +0.000, +0.000], weight: 0.002, band: 3, eig: 5.598, occ: 2.000
Conduction minimum located at kpt index 17:
    spin: 0, kpt: [+0.375, +0.375, +0.000], weight: 0.012, band: 4, eig: 6.161, occ: 0.000

TIP: Use `--verbose` to print k-point coordinates with more digits

To produce a predefined set of matplotlib figures, use:

abiopen.py mgb2_kpath_FATBANDS.nc --expose --seaborn

abiopen_expose

Replace --expose with --notebook to generate a jupyter notebook with predefined python code

If you are still using perl scripts to extract data from the main output file, check this out:

abiopen.py gs_dfpt.abo --expose --seaborn

To visualize all the results inside the web browser, use

abiopen.py out_GRUNS.nc --expose-web # -ew for the short version

Creating dashboards from the command line

  • Creating panels inside a notebook is great if you needs GUIs plus the possibility of executing python code.
  • There are however cases in which we only need a dashboard with widgets to interact with the data.

To open a dashboard for the DDB file from the shell, use the --panel option:

abiopen.py out_DDB --panel  # or -pn if you prefer the short option.

To open a dashboard for the DDB file from the shell, use the --panel option:

Convert structure from netcdf format to CIF (abivars, xsf, poscar, qe, siesta, wannier90, json)

In [6]:
!abistruct.py convert si_scf_GSR.nc -f cif
# generated using pymatgen
data_Si
_symmetry_space_group_name_H-M   'P 1'
_cell_length_a   3.86697464
_cell_length_b   3.86697464
_cell_length_c   3.86697464
_cell_angle_alpha   60.00000000
_cell_angle_beta   60.00000000
_cell_angle_gamma   60.00000000
_symmetry_Int_Tables_number   1
_chemical_formula_structural   Si
_chemical_formula_sum   Si2
_cell_volume   40.88829233
_cell_formula_units_Z   2
loop_
 _symmetry_equiv_pos_site_id
 _symmetry_equiv_pos_as_xyz
  1  'x, y, z'
loop_
 _atom_site_type_symbol
 _atom_site_label
 _atom_site_symmetry_multiplicity
 _atom_site_fract_x
 _atom_site_fract_y
 _atom_site_fract_z
 _atom_site_occupancy
  Si  Si0  1  0.00000000  0.00000000  0.00000000  1
  Si  Si1  1  0.25000000  0.25000000  0.25000000  1

Are you still using cut3d to export the structure in a format that other applications can understand?

abistruct.py visualize run_si02.abi

Supports also ovito, xcrysden, vtk, mayavi, matplotlib (Use --application option)

Read structure from FILE and print ABINIT variables for NSCF along k-path:

In [7]:
!abistruct.py kpath si_scf_GSR.nc
/Users/gmatteo/git_repos/pymatgen/pymatgen/symmetry/kpath.py:179: UserWarning: The input structure does not match the expected standard primitive! The path can be incorrect. Use at your own risk.
  warn(
# Abinit Structure
 natom 2
 ntypat 1
 typat 1 1
 znucl 14
 xred
    0.0000000000    0.0000000000    0.0000000000
    0.2500000000    0.2500000000    0.2500000000
 acell    1.0    1.0    1.0
 rprim
    6.3285005521    0.0000000000    3.6537614973
    2.1095001840    5.9665675402    3.6537614973
    0.0000000000    0.0000000000    7.3075229946

# tolwfr 1e-20 iscf -2 # NSCF run
# To read previous DEN file, use: getden -1 or specify filename via getden_path "out_DEN"

# K-path in reduced coordinates:
 ndivsm 10
 kptopt -11
 kptbounds
    +0.00000  +0.00000  +0.00000  # $\Gamma$
    +0.50000  +0.00000  +0.50000  # X
    +0.50000  +0.25000  +0.75000  # W
    +0.37500  +0.37500  +0.75000  # K
    +0.00000  +0.00000  +0.00000  # $\Gamma$
    +0.50000  +0.50000  +0.50000  # L
    +0.62500  +0.25000  +0.62500  # U
    +0.50000  +0.25000  +0.75000  # W
    +0.50000  +0.50000  +0.50000  # L
    +0.37500  +0.37500  +0.75000  # K
    +0.62500  +0.25000  +0.62500  # U
    +0.50000  +0.00000  +0.50000  # X

Connect to the materials project database to find similar structures.

In [8]:
!abistruct.py mp_match si_scf_GSR.nc
# Found 2 structures in Materials Project database (use `verbose` to get further info)

 
########################### abivars input for this ###########################
# Full Formula (Si2)
# Reduced Formula: Si
# abc   :   3.866975   3.866975   3.866975
# angles:  60.000000  60.000000  60.000000
# 
# Spglib space group info (magnetic symmetries not taken into account).
# Spacegroup: Fd-3m (227), Hall: F 4d 2 3 -1d, Abinit spg_number: 227
# Crystal_system: cubic, Lattice_type: cubic, Point_group: m-3m
# 
#   Idx  Symbol    Reduced_Coords              Wyckoff      EqIdx
# -----  --------  --------------------------  ---------  -------
#     0  Si        +0.00000 +0.00000 +0.00000  (2a)             0
#     1  Si        +0.25000 +0.25000 +0.25000  (2a)             0

 natom 2
 ntypat 1
 typat 1 1
 znucl 14
 xred
    0.0000000000    0.0000000000    0.0000000000
    0.2500000000    0.2500000000    0.2500000000
 acell    1.0    1.0    1.0
 rprim
    6.3285005521    0.0000000000    3.6537614973
    2.1095001840    5.9665675402    3.6537614973
    0.0000000000    0.0000000000    7.3075229946



 
########################## abivars input for mp-149 ##########################
# Full Formula (Si2)
# Reduced Formula: Si
# abc   :   3.866975   3.866975   3.866975
# angles:  60.000000  60.000000  60.000000
# 
# Spglib space group info (magnetic symmetries not taken into account).
# Spacegroup: Fd-3m (227), Hall: F 4d 2 3 -1d, Abinit spg_number: None
# Crystal_system: cubic, Lattice_type: cubic, Point_group: m-3m
# 
#   Idx  Symbol    Reduced_Coords              Wyckoff      EqIdx
# -----  --------  --------------------------  ---------  -------
#     0  Si        +0.25000 +0.25000 +0.25000  (2b)             0
#     1  Si        +0.00000 +0.00000 +0.00000  (2b)             0

 natom 2
 ntypat 1
 typat 1 1
 znucl 14
 xred
    0.2500000000    0.2500000000    0.2500000000
    0.0000000000    0.0000000000    0.0000000000
 acell    1.0    1.0    1.0
 rprim
    0.0000000000    5.1671990850    5.1671990850
    5.1671990850    0.0000000000    5.1671990850
    5.1671990850    5.1671990850    0.0000000000



Need to call anaddb to compute and visualize ph-bands and DOS from DDB?

abiview.py ddb ZnSe_hex_qpt_DDB --seaborn

Add --phononwebsite to visualize data on the phononwebsite by Henrique

In [9]:
!abiview.py --help
usage: abiview.py [-h] [-V]
                  {structure,hist,data,dirviz,ebands,skw,fs,ifermi_fs,ddb,ddb_vs,ddb_ir,ddb_asr,ddb_dipdip,ddb_quad,ddb_isodistort_ph,ddb_ifc,ddb_qpt,phbands,lobster,denpot}
                  ...

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit

subcommands:
  Valid subcommands

  {structure,hist,data,dirviz,ebands,skw,fs,ifermi_fs,ddb,ddb_vs,ddb_ir,ddb_asr,ddb_dipdip,ddb_quad,ddb_isodistort_ph,ddb_ifc,ddb_qpt,phbands,lobster,denpot}
                        sub-command help
    structure           Visualize the structure with the specified visualizer.
                        Requires external app or optional python modules
                        (mayavi, vtk)
    hist                Visualize structural relaxation/molecular-dynamics run
                        from data stored in the HIST.nc file. Requires mayavi.
    data                Extract data from a generic text file with results in
                        tabular format and plot data with matplotlib. Multiple
                        datasets are supported. No attempt is made to handle
                        metadata (e.g. column name)
    dirviz              Visualize directory tree with graphviz.
    ebands              Plot electronic bands if file contains high-symmetry
                        k-path or DOS if k-sampling. Accept any file with
                        ElectronBands e.g. GSR.nc, WFK.nc, ...
    skw                 Interpolate energies in k-space along a k-path with
                        star-function methods Note that the interpolation will
                        likely fail if there are symmetrical k-points in the
                        input set of k-points so it's recommended to call this
                        method with energies obtained in the IBZ. Accept any
                        file with ElectronBands e.g. GSR.nc, WFK.nc, ...
    fs                  Extract eigenvalues in the IBZ from file and visualize
                        Fermi surface with the external application specified
                        via --appname
    ifermi_fs           Use ifermi package to visualize the Fermi surface.
                        Requires netcdf file with energies in the IBZ. See
                        <https://fermisurfaces.github.io/IFermi/>
    ddb                 Invoke Anaddb to compute phonon bands and DOS from the
                        DDB, plot the results.
    ddb_vs              Compute speed of sound by fitting phonon frequencies
                        along selected directions.
    ddb_ir              Compute infra-red spectrum from DDB. Plot results.
    ddb_asr             Compute phonon band structure from DDB with/without
                        acoustic sum rule. Plot results.
    ddb_dipdip          Compute phonon band structure from DDB with/without
                        dipole-dipole interaction. Plot results.
    ddb_quad            Compute phonon band structure from DDB with/without
                        quadrupole terms. Plot results.
    ddb_isodistort_ph   Compute ph-freqs for given q-point (default: Gamma),
                        produce CIF files for unperturbed and distorded
                        structure that can be used with ISODISTORT
                        (https://stokes.byu.edu/iso/isodistort.php) to analyze
                        the symmetry of phonon modes. See README.me file
                        produced in output directory.
    ddb_ifc             Visualize interatomic force constants in real space.
    ddb_qpt             Compute ph-frequencies at the selected q-point without
                        passing through the Fourier interpolation of the
                        interatomic force constants.
    phbands             Plot phonon bands. Accept any file with PhononBands
                        e.g. PHBST.nc, ...
    lobster             Analyze lobster output files in directory.
    denpot              Visualize netcdf DEN/POT files with --appname
                        (default: Vesta). NB: Appplication must be installed
                        and in $PATH.

Usage example:

###########
# Structure
###########

    abiview.py structure FILE                ==> Visualize structure with Vesta (default)
    abiview.py structure FILE -a xcrysden    ==> Visualize structure with Xcrysden (default)
    abiview.py hist out_HIST.nc              ==> Plot relaxation/molecular dynamics results with matplotlib.
    abiview.py hist out_HIST.nc -a ovito     ==> Visualize relaxation/molecular dynamics results with ovito.
    abiview.py hist out_HIST.nc --xdatcar    ==> Convert HIST.nc into XDATCAR format (caveat: assume fixed unit cell!)

############
# Text files
############

    abiview.py data FILE     ==> Parse text FILE with data in tabular format and plot arrays.

###########
# Electrons
###########

    abiview.py ebands out_WFK.nc              ==>  Plot electrons bands (or DOS) with matplotlib.
    abiview.py ebands out_GSR.nc --xmgrace    ==>  Generate xmgrace file with electron bands.
    abiview.py fs FILE_WITH_KMESH.nc          ==>  Visualize Fermi surface from netcdf file with electron energies
                                                   on a k-mesh. Use -a xsf to change application e.g. Xcrysden.
    abiview.py skw out_GSR.nc                 ==> Interpolate IBZ energies with star-functions and plot
                                                  interpolated bands.
    abiview.py denpot out_DEN.nc              ==> Visualize DEN/POT file with Vesta. Use `-a xcrysden` to change app.
    abiview.py denpot out_DEN.nc --chgcar     ==> Convert DEN file to CHGCAR fileformat.

#########
# Phonons
#########

    abiview.py ddb in_DDB                 ==>  Compute ph-bands and DOS from DDB, plot results.
    abiview.py ddb_vs                     ==>  Compute speed of sound from DDB by fitting phonon frequencies.
    abiview.py ddb_ir                     ==>  Compute infra-red spectrum from DDB. Plot results.
    abiview.py ddb_asr                    ==>  Compute ph-bands from DDB with/wo acoustic rule.
                                               Plot results with matplotlib (default) or plotly (--plotly)
    abiview.py ddb_asr --plotly -cs       ==>  Compute ph-bands from DDB with/wo acoustic rule.
                                               Plot results with plotly and push figure
                                               to plotly chart studio cloud. See: https://chart-studio.plotly.com
    abiview.py ddb_dipdip                 ==>  Compute ph-bands from DDB with/wo dipole-dipole treatment.
                                               Plot results with matplotlib (default) or plotly (--plotly)
    abiview.py ddb_quad                   ==>  Compute ph-bands from DDB with/wo dipole-quadrupole terms.
                                               Plot results with matplotlib (default) or plotly (--plotly)
    abiview.py ddb_qpt -q 0 0.5 0         ==>  Compute ph-frequencies at the selected q-point without passing
                                               through the Fourier interpolation of the interatomic force constants.
    abiview.py ddb_ifc                    ==>  Visualize interatomic force constants in real space.
    abiview.py phbands out_PHBST.nc -web  ==>  Visualize ph-bands and displacements with phononwebsite.

###############
# Miscelleanous
###############

  abiview.py dirviz DIRECTORY            ==> Visualize directory tree with graphviz.
  abiview.py lobster DIRECTORY           ==> Visualize Lobster results.

Use `abiview.py --help` for help and `abiview.py COMMAND --help` to get the documentation for `COMMAND`.
Use `-v` to increase verbosity level (can be supplied multiple times e.g -vv).

To compare multiple structures:

In [10]:
!abicomp.py structure *.cif si_nscf_GSR.nc *_DDB
Spglib options: symprec= 0.001 angle_tolerance= 5.0
Lattice parameters:
                  formula  natom  alpha  beta  gamma         a         b  \
si.cif                Si2      2   60.0  60.0   60.0  3.866975  3.866975   
si_nscf_GSR.nc        Si2      2   60.0  60.0   60.0  3.866975  3.866975   
ZnSe_hex_qpt_DDB  Zn2 Se2      4   90.0  90.0  120.0  4.050187  4.050187   
alas_DDB          Al1 As1      2   60.0  60.0   60.0  3.970101  3.970101   
elastic_DDB       Al2 As2      4   90.0  90.0  120.0  3.989448  3.989448   

                         c     volume abispg_num spglib_symb  spglib_num  \
si.cif            3.866975  40.888292       None       Fd-3m         227   
si_nscf_GSR.nc    3.866975  40.888292        227       Fd-3m         227   
ZnSe_hex_qpt_DDB  6.652328  94.504936          0      P6_3mc         186   
alas_DDB          3.970101  44.247584          0       F-43m         216   
elastic_DDB       6.497130  89.552529          0      P6_3mc         186   

                 spglib_lattice_type  
si.cif                         cubic  
si_nscf_GSR.nc                 cubic  
ZnSe_hex_qpt_DDB           hexagonal  
alas_DDB                       cubic  
elastic_DDB                hexagonal  
 

Using ElectronBandsPlotter to visualize multiple band structures:

abicomp.py ebands *_GSR.nc

AbiPy API

AbiPy plots with matplotlib

In [11]:
gsr = abiopen("si_nscf_GSR.nc")
gsr.ebands.plot(with_gaps=True);

AbiPy plots with plotly

In [12]:
gsr.ebands.plotly(with_gaps=True);  # obj.plot becomes obj.plotly

To upload the plotly figure to the chart studio server, use:

gsr.ebands.plotly(with_gaps=True, chart_studio=True);

Users can finally customize the AbiPy plot without changing the python code 🎉

Interactive 3d plots with plotly:

In [13]:
gsr.ebands.kpoints.plotly(title="k-path in 3d with plotly");

and, ça va sans dire, phonons from DDB with plotly:

In [14]:
znse_ddb = abilab.abiopen("ZnSe_hex_qpt_DDB")

phbst_file, phdos_file = znse_ddb.anaget_phbst_and_phdos_files()
phbands, phdos = phbst_file.phbands, phdos_file.phdos

phbands.plotly_with_phdos(phdos, units="cm-1", title="ZnSe Phonon bands + DOS in cm-1");

Bash is handy but python is more flexible

Let's use the DdbRobot to compare phonons obtained with different ${\bf k}$-meshes and smearing values:
In [15]:
paths = [
    "mgb2_888k_0.01tsmear_DDB",
    "mgb2_888k_0.04tsmear_DDB",
    "mgb2_121212k_0.01tsmear_DDB",
    "mgb2_121212k_0.04tsmear_DDB",
]

paths = [os.path.join(abidata.dirpath, "refs", "mgb2_phonons_nkpt_tsmear", f) 
         for f in paths]

robot = abilab.DdbRobot()
for i, path in enumerate(paths):
    robot.add_file(path, path)
In [16]:
# Define function to change labels:
func = lambda ddb: "nkpt: %s, tsmear: %.2f" % (
    ddb.header["nkpt"], ddb.header["tsmear"])

robot.remap_labels(func)
robot
Out[16]:
  1. nkpt: 256, tsmear: 0.01
  2. nkpt: 256, tsmear: 0.04
  3. nkpt: 864, tsmear: 0.01
  4. nkpt: 864, tsmear: 0.04

Now we can build a dataframe with the most important parameters:

In [17]:
robot.get_params_dataframe()
Out[17]:
nkpt nsppol ecut tsmear occopt ixc nband usepaw
nkpt: 256, tsmear: 0.01 256 1 35.0 0.01 4 1 8 0
nkpt: 256, tsmear: 0.04 256 1 35.0 0.04 4 1 8 0
nkpt: 864, tsmear: 0.01 864 1 35.0 0.01 4 1 8 0
nkpt: 864, tsmear: 0.04 864 1 35.0 0.04 4 1 8 0

and check that all DDBs have been computed with the same crystalline structure:

In [18]:
robot.get_lattice_dataframe()
Out[18]:
formula natom alpha beta gamma a b c volume abispg_num spglib_symb spglib_num spglib_lattice_type
nkpt: 256, tsmear: 0.01 Mg1 B2 3 90.0 90.0 120.0 3.086 3.086 3.523 29.055953 0 P6/mmm 191 hexagonal
nkpt: 256, tsmear: 0.04 Mg1 B2 3 90.0 90.0 120.0 3.086 3.086 3.523 29.055953 0 P6/mmm 191 hexagonal
nkpt: 864, tsmear: 0.01 Mg1 B2 3 90.0 90.0 120.0 3.086 3.086 3.523 29.055953 0 P6/mmm 191 hexagonal
nkpt: 864, tsmear: 0.04 Mg1 B2 3 90.0 90.0 120.0 3.086 3.086 3.523 29.055953 0 P6/mmm 191 hexagonal

To analyze the effect of k-sampling/smearing on the vibrational properties:

In [19]:
# Invoke anaddb and store results
r = robot.anaget_phonon_plotters(nqsmall=2)

r.phbands_plotter.gridplot_with_hue("tsmear", with_dos=True);

Quick intro to AbiPy Flows and selected examples

⚠️ There are two different workflow infrastructures:

Internal AbiPy implementation (abipy.flowtk modules):

  • ✅ Lightweigth, no database required
  • ✅ Designed for rapid prototyping and/or for supporting advanced ABINIT capabilities
  • ❌ No explicit support for high-throughput (HT) applications.

AbiFlows package (requires Fireworks and MongoDB database)

  • HT-oriented: use MongoDB to store workflow status and results for further analysis
  • High-level API designed for HT applications (e.g. phonon calculations for the materials project)
  • ❌ Not all the flowtk workflows are immediately available in AbiFlows.

NB: There's an ongoing effort to reimplement AbiFlows in terms of the atomate framework. In this talk, we will mainly discuss the new features available in abipy.flowtk.

Effective masses with DFPT

This flow performs:

  • GS-SCF run followed by NSCF run with k-path to locate band edges automatically
  • Compute $\epsilon^{\alpha\beta}_{n\bf{k}}$ and the effective mass tensor at the band edges using $|u_{n\mathbf{k}}\rangle$, and the k-derivatives $|u_{n\mathbf{k}}^\alpha\rangle$ $H^\alpha_{\mathbf{k}}$, $H^{\alpha\beta}_{\mathbf{k}}$

  • For the formalism, see J. Laflamme Janssen, et. al. Phys. Rev. B 93, 205147

  • More that 1k systems already computed by J. C. Abreu.

Python API:

flow = flowtk.Flow("flow_effmass_dfpt")

# Build input for GS SCF calculation.
scf_input = make_scf_input()

# This object implements all the worflow logic
from abipy.flowtk.effmass_works import EffMassAutoDFPTWork
work = EffMassAutoDFPTWork.from_scf_input(scf_input) 

flow.register_work(work)

Dependency Graph


  • To run the flow with the high-level interface, use: run_effmass_dfpt.py --sheduler
  • autoparal algorithm:
    • select "optimal" Ncpus for each task
    • set MPI-related variables in the input
    • submit tasks and start monitoring
    • indipendent tasks are executed in parallel
  • Support for bluegene, moab, pbspro, sge, shell, slurm, torque
  • Restart capabilities (e.g. timeout limit) and error handlers

To generate a GS-SCF input, one can use factory functions (HT-oriented)

In [21]:
from abipy.abio.factories import gs_input

gs_input(structure="si.cif", pseudos="14si.pspnc", ecut=8)
Out[21]:
##############################################
#### SECTION: basic
##############################################
ecut 8
ngkpt 8 8 8
shiftk 0.5 0.5 0.5
nshiftk 1
kptopt 1
nsppol 2
nband 16
occopt 3
tolvrs 1e-08
##############################################
#### SECTION: files
##############################################
indata_prefix indata/in
tmpdata_prefix tmpdata/tmp
outdata_prefix outdata/out
pseudos /Users/gmatteo/git_repos/abipy_imec_2022/14si.pspnc
##############################################
#### SECTION: gstate
##############################################
spinat
0.0 0.0 0.6
0.0 0.0 0.6
chksymbreak 0
nspinor 1
nspden 2
charge 0.0
tsmear 0.0036749322175655 Ha
##############################################
#### STRUCTURE
##############################################
natom 2
ntypat 1
typat 1 1
znucl 14
xred
0.0000000000 0.0000000000 0.0000000000
0.2500000000 0.2500000000 0.2500000000
acell 1.0 1.0 1.0
rprim
6.3285005244 0.0000000000 3.6537614813
2.1095001748 5.9665675141 3.6537614813
0.0000000000 0.0000000000 7.3075229627

or build it from scratch if full controll is wanted:

In [22]:
other_inp = abilab.AbinitInput(structure="si.cif", pseudos="14si.pspnc")

other_inp.set_vars(ecut=8, nsppol=2, toldfe=1e-8)
other_inp.set_autokmesh(8)

other_inp
Out[22]:
##############################################
#### SECTION: basic
##############################################
ecut 8
nsppol 2
toldfe 1e-08
ngkpt 8 8 8
kptopt 1
nshiftk 4
shiftk
0.5 0.5 0.5
0.5 0.0 0.0
0.0 0.5 0.0
0.0 0.0 0.5
##############################################
#### SECTION: files
##############################################
indata_prefix indata/in
tmpdata_prefix tmpdata/tmp
outdata_prefix outdata/out
pseudos /Users/gmatteo/git_repos/abipy_imec_2022/14si.pspnc
##############################################
#### STRUCTURE
##############################################
natom 2
ntypat 1
typat 1 1
znucl 14
xred
0.0000000000 0.0000000000 0.0000000000
0.2500000000 0.2500000000 0.2500000000
acell 1.0 1.0 1.0
rprim
6.3285005244 0.0000000000 3.6537614813
2.1095001748 5.9665675141 3.6537614813
0.0000000000 0.0000000000 7.3075229627

Obviously, we used an AbiPy script to automate most of the steps:


NB: This is a simplified version with just 2 q-points in the path. In our work, we used 278 points.

How to use AbiPy panels inside jupyter notebooks

To build a panel GUI inside the notebook, call the get_panel method:

In [23]:
ddb = abilab.abiopen("ZnSe_hex_qpt_DDB")

#abilab.abipanel(); # Important
ddb.get_panel()
WARNING:param.Tabs00509: Displaying Panel objects in the notebook requires the panel extension to be loaded. Ensure you run pn.extension() before displaying objects in the notebook.
Out[23]:
Tabs(sizing_mode='stretch_width')
    [0] Terminal(id=140205847988320)
    [1] Row
        [0] Column
            [0] Markdown(str)
            [1] IntInput(name='nqsmall (q-mesh f..., start=1, value=10)
            [2] IntInput(name='ndivsm (density o..., value=5)
            [3] Select(name='Asr', options=OrderedDict([('0', ...]), value=2)
            [4] Select(name='Chneut', options=OrderedDict([('0', ...]), value=1)
            [5] Select(name='Dipdip', options=OrderedDict([('0', ...]), value=1)
            [6] Select(name='Dipquad', options=OrderedDict([('0', ...]), value=1)
            [7] Select(name='Quadquad', options=OrderedDict([('0', ...]), value=1)
            [8] Select(name='Lo to splitting', options=OrderedDict([('automatic',...]), value='automatic')
            [9] Select(name='Integration m..., options=OrderedDict([('tetra', ...]), value='tetra')
            [10] Checkbox(name='Stacked PJDOS', value=True)
            [11] Checkbox(name='Show q-path with plotly', value=True)
            [12] EditableRangeSlider(end=1000, name='T-range in K', step=50, value=(100.0, 400), width=300)
            [13] Divider()
            [14] Button(button_type='primary', name='Plot Bands and DOS')
        [1] ParamMethod(method)
    [2] Row
        [0] Column
            [0] Markdown(str)
            [1] Select(name='Asr', options=OrderedDict([('0', ...]), value=2)
            [2] Select(name='Chneut', options=OrderedDict([('0', ...]), value=1)
            [3] Select(name='Dipdip', options=OrderedDict([('0', ...]), value=1)
            [4] FloatInput(name='Phonon linewidth in eV', start=1e-20, value=0.0001)
            [5] Button(button_type='primary', name='Compute')
        [1] ParamMethod(method)
    [3] Row
        [0] Column
            [0] Markdown(str)
            [1] Select(name='Asr', options=OrderedDict([('0', ...]), value=2)
            [2] Select(name='Chneut', options=OrderedDict([('0', ...]), value=1)
            [3] Select(name='Dipdip', options=OrderedDict([('0', ...]), value=1)
            [4] FloatInput(name='Phonon linewidth in eV', start=1e-20, value=0.0001)
            [5] EditableRangeSlider(name='Frequency range (eV)', step=0.01, value=(0.0, 0.1), width=300)
            [6] Button(button_type='primary', name='Plot eps0(omega)')
        [1] ParamMethod(method)
    [4] Row
        [0] Column
            [0] Markdown(str)
            [1] IntInput(name='Number of q-points', start=1, value=20)
            [2] FloatInput(name='Norm of the l..., start=0, value=0.1)
            [3] Select(name='Asr', options=OrderedDict([('0', ...]), value=2)
            [4] Select(name='Chneut', options=OrderedDict([('0', ...]), value=1)
            [5] Select(name='Dipdip', options=OrderedDict([('0', ...]), value=1)
            [6] Select(name='Dipquad', options=OrderedDict([('0', ...]), value=1)
            [7] Select(name='Quadquad', options=OrderedDict([('0', ...]), value=1)
            [8] Button(button_type='primary', name='Calculate speed o...)
        [1] ParamMethod(method)
    [5] Row
        [0] Column
            [0] Markdown(str)
            [1] LiteralInput(name='nqmall_list (..., type=<class 'list'>, value=[10, 20, 30])
            [2] Select(name='Integration m..., options=OrderedDict([('tetra', ...]), value='tetra')
            [3] Select(name='Asr', options=OrderedDict([('0', ...]), value=2)
            [4] Select(name='Chneut', options=OrderedDict([('0', ...]), value=1)
            [5] Select(name='Dipdip', options=OrderedDict([('0', ...]), value=1)
            [6] Select(name='Dipquad', options=OrderedDict([('0', ...]), value=1)
            [7] Select(name='Quadquad', options=OrderedDict([('0', ...]), value=1)
            [8] EditableRangeSlider(end=1000, name='T-range in K', step=50, value=(100.0, 400), width=300)
            [9] Button(button_type='primary', name='Plot PHDos vs Qmesh')
        [1] ParamMethod(method)
    [6] Row
        [0] Column
            [0] Markdown(str)
            [1] IntInput(name='nqsmall (q-mesh f..., start=1, value=10)
            [2] IntInput(name='ndivsm (density o..., value=5)
            [3] Select(name='Integration m..., options=OrderedDict([('tetra', ...]), value='tetra')
            [4] Button(button_type='primary', name='Compute phonons w...)
        [1] ParamMethod(method)
    [7] Row
        [0] Column
            [0] Markdown(str)
            [1] Select(name='Asr', options=OrderedDict([('0', ...]), value=2)
            [2] Select(name='Dipdip', options=OrderedDict([('0', ...]), value=1)
            [3] Select(name='Chneut', options=OrderedDict([('0', ...]), value=1)
            [4] Select(name='Scale for IFCs', options=OrderedDict([('log', ...]), value='log')
            [5] Button(button_type='primary', name='Compute IFC(R)')
        [1] ParamMethod(method)
    [8] Row
        [0] Column
            [0] Markdown(str)
            [1] Select(name='Structure viewer', options=OrderedDict([('jsmol', ...]), value='jsmol')
            [2] Button(button_type='primary', name='View structure')
        [1] Column
            [0] ParamMethod(method)
            [1] Column(sizing_mode='scale_width')
                [0] Markdown(str)
                [1] Column(sizing_mode='stretch_both')
                    [0] Tabulator(disabled=True, sizing_mode='scale_width', value=              ...)
                    [1] Divider()
                [2] Markdown(str)
                [3] Column(sizing_mode='stretch_both')
                    [0] Tabulator(disabled=True, sizing_mode='scale_width', value=              ...)
                    [1] Divider()
                [4] Markdown(str)
                [5] Column(sizing_mode='stretch_both')
                    [0] Tabulator(disabled=True, sizing_mode='scale_width', value=              ...)
                    [1] Divider()
                [6] Accordion(sizing_mode='stretch_width')
                    [0] Column(sizing_mode='stretch_both')
                        [0] Tabulator(disabled=True, sizing_mode='scale_width', value=                          ...)
                        [1] Divider()
                    [1] Column(sizing_mode='stretch_both')
                        [0] Tabulator(disabled=True, sizing_mode='scale_width', value=                          ...)
                        [1] Divider()
    [9] Row
        [0] Column
            [0] Markdown(str)
            [1] Select(name='Units', options=OrderedDict([('eV', ...]), value='eV')
            [2] IntInput(name='Mpi procs', start=1, value=1)
            [3] IntInput(name='Verbose', start=0)
        [1] Column(sizing_mode='scale_width')
            [0] Markdown(str)
            [1] Column(sizing_mode='stretch_both')
                [0] Tabulator(disabled=True, sizing_mode='scale_width', value=              ...)
                [1] Divider()
Don't be surprised if you start to click buttons and nothing happens in the GUI! One needs a python backend to execute the callbacks triggered by the widgets.

Documentation for these new features available at:

In [25]:
%embed https://abinit.github.io/abipy/graphical_interface.html
Out[25]:

How to run AbiPy Flows

In order to run a Flow, we need two configurations files:

  1. scheduler.yml providing:

    • scheduler parameters such as days, hours, minutes, max_njobs_inqueue, max_ncores_used, …
  1. manager.yml providing:

    • list of shell commands to be executed before running ABINIT
    • list of modules to load
    • options for the queue manager (bluegene, moab, pbspro, sge, shell, slurm, torque)

See this page for examples or use the abidoc.py script and the syntax:

  • abidoc.py scheduler
  • abidoc.py manager
  • abidoc.py manager slurm

How to run calculations?

The simplest way to start the scheduler from the shell is via the syntax:

run_elastic.py --scheduler # -s for the short option

For non-trivial Flows, we suggest to put the scheduler in background and use nohup so that we can disconnect from the shell session without killing the scheduler.

nohup run_elastic.py --s > log 2> err &

Obviously, it is possible to submit a Slurm script that executes the script on the compute note with 1 core.

To interact with the Flow, one can also use the abirun.py script, e.g:

abirun.py FLOWDIR status